// 邻接表测试

#include <iostream>
#include "algraph.h"

using namespace std;

int main()
{
    // 建立图
    // G = ({A,B,C,D,E},{AB,AC,BE,CB,CD,DB,EA,ED})
    ALGraph<char, int> G;
    InitGraph(G);

    int a = AddVertex(G, 'A');
    int b = AddVertex(G, 'B');
    int c = AddVertex(G, 'C');
    int d = AddVertex(G, 'D');
    int e = AddVertex(G, 'E');

    AddArc(G, a, b, 1);
    AddArc(G, a, c, 1);
    AddArc(G, b, e, 1);
    AddArc(G, c, b, 1);
    AddArc(G, c, d, 1);
    AddArc(G, d, b, 1);
    AddArc(G, e, a, 1);
    AddArc(G, e, d, 1);

    // 深度优先搜索
    auto print = [](char c) { cout << c; };
    cout << "DFSTraverse:  ";
    DFSTraverse(G, print);

    cout << "\nBFSTraverse:  ";
    BFSTraverse(G, print);

    DestroyGraph(G);

    return 0;
}